
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>观察者模式 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../../../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../mediatormode/" />
    
    
    <link rel="prev" href="../statemode/" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../../../../">
            
                <a href="../../../../../../">
            
                    
                    说明
            
                </a>
            

            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../../../../">
            
                <a href="../../../../../">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" >
            
                <span>
            
                    
                    创建型模式
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1.1" >
            
                <span>
            
                    
                    简单工厂模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.2" >
            
                <span>
            
                    
                    工厂方法模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.3" data-path="../../createdmodel/abstractfactorymode/">
            
                <a href="../../createdmodel/abstractfactorymode/">
            
                    
                    抽象工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.4" data-path="../../createdmodel/bulidermode/">
            
                <a href="../../createdmodel/bulidermode/">
            
                    
                    建造者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.5" data-path="../../createdmodel/prototypemode/">
            
                <a href="../../createdmodel/prototypemode/">
            
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.6" data-path="../../createdmodel/singletonmode/">
            
                <a href="../../createdmodel/singletonmode/">
            
                    
                    单例模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../../structuredmodel/">
            
                <a href="../../structuredmodel/">
            
                    
                    结构型模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.2.1" data-path="../../structuredmodel/proxymode/">
            
                <a href="../../structuredmodel/proxymode/">
            
                    
                    代理模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.2" data-path="../../structuredmodel/adaptermode/">
            
                <a href="../../structuredmodel/adaptermode/">
            
                    
                    适配器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.3" data-path="../../structuredmodel/bridgemode/">
            
                <a href="../../structuredmodel/bridgemode/">
            
                    
                    桥接模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.4" data-path="../../structuredmodel/decoratormode/">
            
                <a href="../../structuredmodel/decoratormode/">
            
                    
                    装饰模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.5" data-path="../../structuredmodel/facademode/">
            
                <a href="../../structuredmodel/facademode/">
            
                    
                    外观模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.6" data-path="../../structuredmodel/flyweightmode/">
            
                <a href="../../structuredmodel/flyweightmode/">
            
                    
                    享元模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.7" data-path="../../structuredmodel/compositemode/">
            
                <a href="../../structuredmodel/compositemode/">
            
                    
                    组合模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../">
            
                <a href="../">
            
                    
                    行为型模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.3.1" data-path="../templatemethodmode/">
            
                <a href="../templatemethodmode/">
            
                    
                    模板方法模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.2" data-path="../strategymode/">
            
                <a href="../strategymode/">
            
                    
                    策略模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.3" data-path="../commandmode/">
            
                <a href="../commandmode/">
            
                    
                    命令模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.4" data-path="../chainofresponsibility/">
            
                <a href="../chainofresponsibility/">
            
                    
                    责任链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.5" data-path="../statemode/">
            
                <a href="../statemode/">
            
                    
                    状态模式
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.1.3.6" data-path="./">
            
                <a href="./">
            
                    
                    观察者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.7" data-path="../mediatormode/">
            
                <a href="../mediatormode/">
            
                    
                    中介者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.8" data-path="../iteratormode/">
            
                <a href="../iteratormode/">
            
                    
                    迭代器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.9" data-path="../visitormode/">
            
                <a href="../visitormode/">
            
                    
                    访问者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.10" data-path="../mementomode/">
            
                <a href="../mementomode/">
            
                    
                    备忘录模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.11" data-path="../interpretermode/">
            
                <a href="../interpretermode/">
            
                    
                    解释器模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../../../../../../Nacos/">
            
                <a href="../../../../../../Nacos/">
            
                    
                    Nacos
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../../../../../../Nacos/Nacos-Introduction.html">
            
                <a href="../../../../../../Nacos/Nacos-Introduction.html">
            
                    
                    Nacos介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../../../../../../Nacos/Nacos-Registration.html">
            
                <a href="../../../../../../Nacos/Nacos-Registration.html">
            
                    
                    Nacos注册中心
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../../../../../../Nacos/Nacos-OpenFeign.html">
            
                <a href="../../../../../../Nacos/Nacos-OpenFeign.html">
            
                    
                    Nacos+OpenFeign
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../../../../../Sortings/">
            
                <a href="../../../../../../Sortings/">
            
                    
                    排序算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../../../../../../Sortings/src/main/java/com/larscheng/www/InsertionSort/">
            
                <a href="../../../../../../Sortings/src/main/java/com/larscheng/www/InsertionSort/">
            
                    
                    插入排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../../../../../../Sortings/src/main/java/com/larscheng/www/shellSort/">
            
                <a href="../../../../../../Sortings/src/main/java/com/larscheng/www/shellSort/">
            
                    
                    希尔排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" >
            
                <span>
            
                    
                    选择排序
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" >
            
                <span>
            
                    
                    堆排序
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" >
            
                <span>
            
                    
                    希尔排序
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../../../../.." >观察者模式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;">&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;</h3>
<p>&#x5F88;&#x591A;&#x5BF9;&#x8C61;&#x4E0D;&#x662F;&#x72EC;&#x7ACB;&#x5B58;&#x5728;&#x7684;&#xFF0C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x4F1A;&#x5BFC;&#x81F4;&#x5176;&#x4ED6;&#x51E0;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x884C;&#x4E3A;&#x4E5F;&#x53D1;&#x751F;&#x76F8;&#x5E94;&#x53D8;&#x5316;&#x3002;</p>
<p>&#x6BD4;&#x5982;&#xFF0C;&#x4ECA;&#x5929;&#x7684;&#x996D;&#x5F88;&#x4FBF;&#x5B9C;&#x987E;&#x5BA2;&#x5F88;&#x591A;&#xFF0C;&#x660E;&#x5929;&#x7684;&#x996D;&#x5F88;&#x8D35;&#x987E;&#x5BA2;&#x4F1A;&#x76F8;&#x5E94;&#x51CF;&#x5C11;&#xFF1B;&#x7EA2;&#x7EFF;&#x706F;&#x4E3A;&#x7EFF;&#x706F;&#xFF0C;&#x8F66;&#x8F86;&#x4F1A;&#x76F4;&#x63A5;&#x901A;&#x8FC7;&#xFF0C;&#x4E3A;&#x7EA2;&#x706F;&#xFF0C;&#x8F66;&#x8F86;&#x4F1A;&#x505C;&#x6B62;</p>
<p>&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x5C31;&#x662F;&#x7528;&#x6765;&#x5904;&#x7406;&#x8FD9;&#x79CD;&#x573A;&#x666F;</p>
<p>&#x5B9A;&#x4E49;&#xFF1A;&#x591A;&#x4E2A;&#x5BF9;&#x8C61;&#x95F4;&#x5B58;&#x5728;&#x4E00;&#x5BF9;&#x591A;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x65F6;&#xFF0C;&#x5F53;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x72B6;&#x6001;&#x53D1;&#x751F;&#x6539;&#x53D8;&#xFF0C;&#x6240;&#x6709;&#x4F9D;&#x8D56;&#x7684;&#x5BF9;&#x8C61;&#x90FD;&#x4F1A;&#x5F97;&#x5230;&#x901A;&#x77E5;&#x5E76;&#x81EA;&#x52A8;&#x66F4;&#x65B0;&#x3002;</p>
<p>&#x53C8;&#x79F0;&#x4F5C;&#x53D1;&#x5E03;-&#x8BA2;&#x9605;&#x6A21;&#x5F0F;&#x3001;&#x6A21;&#x578B;-&#x89C6;&#x56FE;&#x6A21;&#x5F0F;&#xFF0C;&#x5C5E;&#x4E8E;&#x5BF9;&#x8C61;&#x884C;&#x4E3A;&#x578B;&#x6A21;&#x5F0F;</p>
<h3 id="&#x4F18;&#x7F3A;&#x70B9;">&#x4F18;&#x7F3A;&#x70B9;</h3>
<p>&#x4F18;&#x70B9;&#xFF1A;</p>
<p>&#x964D;&#x4F4E;&#x4E86;&#x5BF9;&#x8C61;&#x95F4;&#x7684;&#x8026;&#x5408;&#x3001;&#x76EE;&#x6807;&#x4E0E;&#x89C2;&#x5BDF;&#x8005;&#x4E4B;&#x95F4;&#x6709;&#x53D8;&#x5316;&#x540E;&#x7684;&#x89E6;&#x53D1;&#x673A;&#x5236;</p>
<p>&#x7F3A;&#x70B9;&#xFF1A;&#x89C2;&#x5BDF;&#x8005;&#x6570;&#x91CF;&#x8FC7;&#x591A;&#xFF0C;&#x901A;&#x77E5;&#x53D1;&#x5E03;&#x8017;&#x65F6;&#x957F;&#xFF0C;&#x5F71;&#x54CD;&#x6548;&#x7387;</p>
<h3 id="&#x89D2;&#x8272;&#x548C;&#x5B9E;&#x73B0;">&#x89D2;&#x8272;&#x548C;&#x5B9E;&#x73B0;</h3>
<ul>
<li>&#x62BD;&#x8C61;&#x4E3B;&#x9898;&#x89D2;&#x8272;&#xFF1A;&#x62BD;&#x8C61;&#x76EE;&#x6807;&#x7C7B;&#xFF0C;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x4FDD;&#x5B58;&#x89C2;&#x5BDF;&#x8005;&#x5BF9;&#x8C61;&#x7684;&#x805A;&#x96C6;&#x7C7B;&#x548C;&#x7528;&#x4E8E;&#x5173;&#x7CFB;&#x89C2;&#x8005;&#x8005;&#x5BF9;&#x8C61;&#x7684;&#x57FA;&#x672C;&#x65B9;&#x6CD5;&#xFF0C;&#x4EE5;&#x53CA;&#x901A;&#x77E5;&#x89C2;&#x5BDF;&#x8005;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;</li>
<li>&#x5177;&#x4F53;&#x4E3B;&#x9898;&#x89D2;&#x8272;&#xFF1A;&#x5177;&#x4F53;&#x76EE;&#x6807;&#x7C7B;&#xFF0C;&#x5B9E;&#x73B0;&#x62BD;&#x8C61;&#x76EE;&#x6807;&#x4E2D;&#x7684;&#x901A;&#x77E5;&#x65B9;&#x6CD5;&#xFF0C;&#x5F53;&#x5177;&#x4F53;&#x7684;&#x5185;&#x90E8;&#x72B6;&#x6001;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x65F6;&#x6CA1;&#x901A;&#x77E5;&#x6240;&#x6709;&#x7684;&#x89C2;&#x5BDF;&#x8005;</li>
<li>&#x62BD;&#x8C61;&#x89C2;&#x5BDF;&#x8005;&#x89D2;&#x8272;&#xFF1A;&#x5305;&#x542B;&#x66F4;&#x65B0;&#x81EA;&#x8EAB;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;</li>
<li>&#x5177;&#x4F53;&#x89C2;&#x5BDF;&#x8005;&#x89D2;&#x8272;&#xFF1A;&#x5B9E;&#x73B0;&#x62BD;&#x8C61;&#x89C2;&#x5BDF;&#x8005;&#x4E2D;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;</li>
</ul>
<p><img src="http://c.biancheng.net/uploads/allimg/181116/3-1Q1161A6221S.gif" alt=""></p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> observer;
<span class="hljs-keyword">import</span> java.util.*;
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ObserverPattern</span>
</span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span>
    </span>{
        Subject subject=<span class="hljs-keyword">new</span> ConcreteSubject();
        Observer obs1=<span class="hljs-keyword">new</span> ConcreteObserver1();
        Observer obs2=<span class="hljs-keyword">new</span> ConcreteObserver2();
        subject.add(obs1);
        subject.add(obs2);
        subject.notifyObserver();
    }
}
<span class="hljs-comment">//&#x62BD;&#x8C61;&#x76EE;&#x6807;</span>
<span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Subject</span>
</span>{
    <span class="hljs-keyword">protected</span> List&lt;Observer&gt; observers=<span class="hljs-keyword">new</span> ArrayList&lt;Observer&gt;();   
    <span class="hljs-comment">//&#x589E;&#x52A0;&#x89C2;&#x5BDF;&#x8005;&#x65B9;&#x6CD5;</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">add</span><span class="hljs-params">(Observer observer)</span>
    </span>{
        observers.add(observer);
    }    
    <span class="hljs-comment">//&#x5220;&#x9664;&#x89C2;&#x5BDF;&#x8005;&#x65B9;&#x6CD5;</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">remove</span><span class="hljs-params">(Observer observer)</span>
    </span>{
        observers.remove(observer);
    }   
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">void</span> <span class="hljs-title">notifyObserver</span><span class="hljs-params">()</span></span>; <span class="hljs-comment">//&#x901A;&#x77E5;&#x89C2;&#x5BDF;&#x8005;&#x65B9;&#x6CD5;</span>
}
<span class="hljs-comment">//&#x5177;&#x4F53;&#x76EE;&#x6807;</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ConcreteSubject</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Subject</span>
</span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">notifyObserver</span><span class="hljs-params">()</span>
    </span>{
        System.out.println(<span class="hljs-string">&quot;&#x5177;&#x4F53;&#x76EE;&#x6807;&#x53D1;&#x751F;&#x6539;&#x53D8;...&quot;</span>);
        System.out.println(<span class="hljs-string">&quot;--------------&quot;</span>);       

        <span class="hljs-keyword">for</span>(Object obs:observers)
        {
            ((Observer)obs).response();
        }

    }          
}
<span class="hljs-comment">//&#x62BD;&#x8C61;&#x89C2;&#x5BDF;&#x8005;</span>
<span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Observer</span>
</span>{
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">response</span><span class="hljs-params">()</span></span>; <span class="hljs-comment">//&#x53CD;&#x5E94;</span>
}
<span class="hljs-comment">//&#x5177;&#x4F53;&#x89C2;&#x5BDF;&#x8005;1</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ConcreteObserver1</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Observer</span>
</span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">response</span><span class="hljs-params">()</span>
    </span>{
        System.out.println(<span class="hljs-string">&quot;&#x5177;&#x4F53;&#x89C2;&#x5BDF;&#x8005;1&#x4F5C;&#x51FA;&#x53CD;&#x5E94;&#xFF01;&quot;</span>);
    }
}
<span class="hljs-comment">//&#x5177;&#x4F53;&#x89C2;&#x5BDF;&#x8005;1</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ConcreteObserver2</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Observer</span>
</span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">response</span><span class="hljs-params">()</span>
    </span>{
        System.out.println(<span class="hljs-string">&quot;&#x5177;&#x4F53;&#x89C2;&#x5BDF;&#x8005;2&#x4F5C;&#x51FA;&#x53CD;&#x5E94;&#xFF01;&quot;</span>);
    }
}
</code></pre>
<h3 id="&#x6A21;&#x62DF;&#x573A;&#x666F;">&#x6A21;&#x62DF;&#x573A;&#x666F;</h3>
<p>&#x5E73;&#x65F6;&#x770B;&#x76F4;&#x64AD;&#x6709;&#x8FD9;&#x6837;&#x4E00;&#x4E2A;&#x573A;&#x666F;</p>
<p>&#x4F60;&#x559C;&#x6B22;&#x770B;pdd&#x76F4;&#x64AD;&#xFF0C;&#x5728;pdd&#x76F4;&#x64AD;&#x95F4;&#x70B9;&#x4E86;&#x5173;&#x6CE8;&#xFF0C;&#x5E76;&#x5F00;&#x542F;&#x7684;&#x5F00;&#x64AD;&#x901A;&#x77E5;</p>
<p>&#x6709;&#x4E00;&#x5929;pdd&#x5F00;&#x76F4;&#x64AD;&#x4E86;&#xFF0C;&#x76F4;&#x64AD;&#x5E73;&#x53F0;&#x5C31;&#x5411;&#x5173;&#x6CE8;&#x4ED6;&#x7684;&#x7528;&#x6237;&#x53D1;&#x901A;&#x77E5;&#xFF0C;&#x7136;&#x540E;&#x89C2;&#x4F17;&#x4EEC;&#x90FD;&#x6253;&#x5F00;app&#x6765;&#x770B;&#x76F4;&#x64AD;</p>
<p>&#x5176;&#x4E2D;&#xFF1A;</p>
<ul>
<li>&#x62BD;&#x8C61;&#x4E3B;&#x9898;&#x89D2;&#x8272;&#xFF1A;&#x76F4;&#x64AD;</li>
<li>&#x5177;&#x4F53;&#x4E3B;&#x9898;&#x89D2;&#x8272;&#xFF1A;pdd&#x76F4;&#x64AD;</li>
<li>&#x62BD;&#x8C61;&#x89C2;&#x5BDF;&#x8005;&#xFF1A;&#x7C89;&#x4E1D;&#x4EEC;</li>
<li>&#x5177;&#x4F53;&#x89C2;&#x5BDF;&#x8005;&#xFF1A;&#x7C89;&#x4E1D;&#x5C0F;&#x738B;&#x3001;&#x7C89;&#x4E1D;&#x5C0F;&#x674E;</li>
</ul>
<p>&#x8FD9;&#x4E2A;&#x573A;&#x666F;&#x7528;&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x63CF;&#x8FF0;&#x4E0B;</p>
<p><img src="https://raw.githubusercontent.com/larscheng/myImg/master/blogImg/DesignPatterns/20190716164327.png" alt=""></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../statemode/" class="navigation navigation-prev " aria-label="Previous page: 状态模式">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../mediatormode/" class="navigation navigation-next " aria-label="Next page: 中介者模式">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"观察者模式","level":"2.1.3.6","depth":3,"next":{"title":"中介者模式","level":"2.1.3.7","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/mediatormode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/mediatormode/README.md","articles":[]},"previous":{"title":"状态模式","level":"2.1.3.5","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/statemode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/statemode/README.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["expandable-chapters","livereload"],"pluginsConfig":{"expandable-chapters":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Design-Patterns/src/main/java/behavioralmodel/observermode/README.md","mtime":"2019-07-16T08:45:33.106Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-09T07:20:35.937Z"},"basePath":"../../../../../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../../../../../gitbook/gitbook.js"></script>
    <script src="../../../../../../gitbook/theme.js"></script>
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

